﻿using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MyDMS.BusinessLayer;
using MyDMS.BusinessLayer.DataLayer;
using System.Collections.ObjectModel;
using WorldClock;

public partial class admin_Setup : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        //  http://msdn.microsoft.com/en-us/library/bb397781.aspx

        //http://www.codeproject.com/KB/dotnet/WorldClock.aspx?fid=126704&df=90&mpp=25&noise=3&sort=Position&view=Quick

        TimeZoneInfo[] tzCollection = TimeZoneInfo.EnumZones();//.GetSystemTimeZones();
        foreach (TimeZoneInfo tzi in tzCollection)
        {
            this.ddlTimeZone.Items.Add(new ListItem(tzi.DisplayName, tzi.Name));
        }
    }
    protected void btnSave_Click(object sender, EventArgs e)
    {
        Office office = new Office();
        office.Office_Name = txtOfcName.Text;

        string filePath = Server.MapPath("~/Upload/Logos/") + fluLogo.FileName;
        fluLogo.SaveAs(filePath);

        office.Office_Logo_Path = filePath;
        office.Office_Slogan = txtSlogan.Text;
        office.Street_Address = txtAddress.Text;
        office.City = txtCity.Text;
        office.Country = txtCountry.Text;
        office.ZIP_Code = txtZip.Text;
        office.TimeZone_Code = ddlTimeZone.SelectedIndex;
        office.Account_Email = txtEmail.Text;
        office.Account_Password = txtPass1.Text;

        OfficeFactory ofc = new OfficeFactory();
        if (ofc.Insert(office))
        {
            lblMessage.Text = "Saved Successfully";
        }
        else
        {
            lblMessage.Text = "Error!";
        }
        lblMessage.Visible = true;
    }
}
